package com.horse.cloud.boss.exception;




import com.horse.cloud.framework.general.enums.ResponseCodeEnums;

import java.io.Serializable;

/**
 * @create : Created by intelliJ IDEA 16.1.3
 * @author : bing.Pan
 * @e-mail : 15923508369@163.com
 * @gmdate : 2017/2/6 20:46
 * @sidesc : 配置类异常
 */
public class ConfigException extends Exception implements Serializable {

    private static final long serialVersionUID = -1695036681341844113L;


    /**
     *错误主码
     */
    private int     errorCode;
    /**
     * 错误子码
     */
    private int     subErrorCode;
    /**
     *错误描述
     */
    private String  errorMsg;
    /**
     *错误详细描述
     */
    private String  detailErrorMsg;

    public ConfigException(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public ConfigException(int errorCode, int subErrorCode, String errorMsg, String detailErrorMsg) {
        this.errorCode      = errorCode;
        this.subErrorCode   = subErrorCode;
        this.errorMsg       = errorMsg;
        this.detailErrorMsg = detailErrorMsg;
    }

    public ConfigException(ResponseCodeEnums responseCodeEnums) {
        this.errorCode      = responseCodeEnums.getCode();
        this.subErrorCode   = responseCodeEnums.getSubCode();
        this.errorMsg       = responseCodeEnums.getDescription();
        this.detailErrorMsg = responseCodeEnums.getDetailMessage();
    }


    public ConfigException(ResponseCodeEnums responseCodeEnums, String detailErrorMsg) {

        this.errorCode      = responseCodeEnums.getCode();
        this.subErrorCode   = responseCodeEnums.getSubCode();
        this.errorMsg       = responseCodeEnums.getDescription();
        this.detailErrorMsg = detailErrorMsg;
    }



    public ConfigException(ConfigException e) {
        this.errorCode      = e.getErrorCode();
        this.subErrorCode   = e.getSubErrorCode();
        this.errorMsg       = e.getMessage();
        this.detailErrorMsg = e.getDetailErrorMsg();

    }

    public ConfigException(Exception e) {
        this.errorCode      = ResponseCodeEnums.SERVER_UNKNOWN_ERROR.getCode();
        this.subErrorCode   = ResponseCodeEnums.SERVER_UNKNOWN_ERROR.getSubCode();
        this.errorMsg       = ResponseCodeEnums.SERVER_UNKNOWN_ERROR.getDescription();
        this.detailErrorMsg = ResponseCodeEnums.SERVER_UNKNOWN_ERROR.getDetailMessage();
    }


    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    public int getSubErrorCode() {
        return subErrorCode;
    }

    public void setSubErrorCode(int subErrorCode) {
        this.subErrorCode = subErrorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public String getDetailErrorMsg() {
        return detailErrorMsg;
    }

    public void setDetailErrorMsg(String detailErrorMsg) {
        this.detailErrorMsg = detailErrorMsg;
    }
}
